﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Eartag.Domain.Model;
using S.Eartag.Domain;
using S.Eartag.Read.API.Application.Command.MarkedConditionCommand;
using PublicClass;
using S.Eartag.Infrastructure.Migrations;

namespace S.Eartag.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MarkedConditionController : ControllerBase
    {
        private readonly IMediator mediator;

        public MarkedConditionController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 羊只戴标显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfoS<Mark>> GetMark([FromQuery]MarkedConditionGetCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 戴标原因
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetReason()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<Reason>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 戴标状态
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMarkedCondition()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<MarkedCondition>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 羊只戴标反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Mark> MarkedFind([FromQuery]MarkedConditionFindCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 耳号下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SelectList>> MarkedGetEar([FromQuery]MarkedConditionGetEarCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
